<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
    <title>用户管理</title>
    <meta name="decorator" content="default"/>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#no").focus();
            $("#inputForm").validate({
                rules: {
                    loginName: {remote: "${ctx}/sys/sysUser/checkLoginName?oldLoginName=" + encodeURIComponent('${sysUser.loginName}')}
                },
                messages: {
                    loginName: {remote: "用户登录名已存在"},
                    confirmNewPassword: {equalTo: "输入与上面相同的密码"}
                },
                submitHandler: function (form) {
                    loading('正在提交，请稍等...');
                    form.submit();
                },
                errorContainer: "#messageBox",
                errorPlacement: function (error, element) {
                    $("#messageBox").text("输入有误，请先更正。");
                    if (element.is(":checkbox") || element.is(":radio") || element.parent().is(".input-append")) {
                        error.appendTo(element.parent().parent());
                    } else {
                        error.insertAfter(element);
                    }
                }
            });
        });
    </script>
</head>
<body>
<ul class="nav nav-tabs">
    <li>
        <a href="${ctx}/sys/sysUser/list">用户列表</a>
    </li>
    <li class="active">
        <a href="${ctx}/sys/sysUser/form?id=${sysUser.id}">
            用户<shiro:hasPermission name="sys:sysUser:edit">${not empty sysUser.id?'修改':'添加'}</shiro:hasPermission>
            <shiro:lacksPermission name="sys:sysUser:edit">查看 </shiro:lacksPermission>
        </a>
    </li>
</ul>
<br/>
<form:form id="inputForm" modelAttribute="sysUser" action="${ctx}/sys/sysUser/save" method="post" class="form-horizontal">
    <form:hidden path="id"/>
    <sys:message content="${message}"/>
    <%--<div class="control-group">--%>
        <%--<label class="control-label">头像:</label>--%>
        <%--<div class="controls">--%>
            <%--<form:hidden id="nameImage" path="photo" htmlEscape="false" maxlength="255" class="input-xlarge"/>--%>
            <%--<sys:ckfinder input="nameImage" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>--%>
        <%--</div>--%>
    <%--</div>--%>
    <div class="control-group">
        <label class="control-label">归属机构:</label>
        <div class="controls">
            <sys:treeselect id="officeId" name="officeId" value="${sysUser.officeId}" title="机构" url="/sys/sysOffice/treeData?type=2" labelValueUrl="/sys/sysOffice/treeValue" cssClass="required" notAllowSelectParent="true"/>
        </div>
    </div>
    <%--<div class="control-group">--%>
        <%--<label class="control-label">工号:</label>--%>
        <%--<div class="controls">--%>
            <%--<form:input path="no" htmlEscape="false" maxlength="50" class="required"/>--%>
            <%--<span class="help-inline" style="color:red">*</span>--%>
        <%--</div>--%>
    <%--</div>--%>
    <div class="control-group">
        <label class="control-label">姓名:</label>
        <div class="controls">
            <form:input path="name" htmlEscape="false" maxlength="50" class="required"/>
            <span class="help-inline" style="color:red">*</span>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">登录名:</label>
        <div class="controls">
            <input id="oldLoginName" name="oldLoginName" type="hidden" value="${sysUser.loginName}">
            <form:input path="loginName" htmlEscape="false" maxlength="50" class="required userName"/>
            <span class="help-inline" style="color:red">*</span>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">密码:</label>
        <div class="controls">
            <input id="newPassword" name="newPassword" type="password" value="" maxlength="50" minlength="3" class="${empty sysUser.id?'required':''}"/>
            <c:if test="${empty sysUser.id}"><span class="help-inline" style="color:red">*</span></c:if>
            <c:if test="${not empty sysUser.id}"><span class="help-inline">若不修改密码，请留空。</span></c:if>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">确认密码:</label>
        <div class="controls">
            <input id="confirmNewPassword" name="confirmNewPassword" type="password" value="" maxlength="50" minlength="3" equalTo="#newPassword"/>
            <c:if test="${empty sysUser.id}"><span class="help-inline" style="color:red">*</span></c:if>
        </div>
    </div>
    <%--<div class="control-group">--%>
        <%--<label class="control-label">邮箱:</label>--%>
        <%--<div class="controls">--%>
            <%--<form:input path="email" htmlEscape="false" maxlength="100" class="email"/>--%>
        <%--</div>--%>
    <%--</div>--%>
    <%--<div class="control-group">--%>
        <%--<label class="control-label">电话:</label>--%>
        <%--<div class="controls">--%>
            <%--<form:input path="phone" htmlEscape="false" maxlength="100"/>--%>
        <%--</div>--%>
    <%--</div>--%>
    <div class="control-group">
        <label class="control-label">手机:</label>
        <div class="controls">
            <form:input path="mobile" htmlEscape="false" maxlength="100"/>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">是否允许登录:</label>
        <div class="controls">
            <form:select path="loginFlag">
                <form:options items="${fns:getDataDictItemList('yes_no')}" itemLabel="itemName" itemValue="itemCode" htmlEscape="false"/>
            </form:select>
            <span class="help-inline" style="color:red">*</span>
            <span class="help-inline">“是”代表此账号允许登录，“否”则表示此账号不允许登录</span>
        </div>
    </div>
    <%--<div class="control-group">--%>
        <%--<label class="control-label">用户类型:</label>--%>
        <%--<div class="controls">--%>
            <%--<form:select path="userType" class="input-xlarge">--%>
                <%--<form:option value="" label="请选择"/>--%>
                <%--<form:options items="${fns:getDataDictItemList('sys_user_type')}" itemLabel="itemName" itemValue="itemCode" htmlEscape="false"/>--%>
            <%--</form:select>--%>
        <%--</div>--%>
    <%--</div>--%>
    <div class="control-group">
        <label class="control-label">用户角色:</label>
        <div class="controls">
            <form:checkboxes path="roleIdList" items="${allRoles}" itemLabel="name" itemValue="id" htmlEscape="false" class="required"/>
            <span class="help-inline" style="color:red">*</span>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">备注:</label>
        <div class="controls">
            <form:textarea path="remarks" htmlEscape="false" rows="3" maxlength="200" class="input-xlarge"/>
        </div>
    </div>
    <%--<c:if test="${not empty sysUser.id}">--%>
        <%--<div class="control-group">--%>
            <%--<label class="control-label">创建时间:</label>--%>
            <%--<div class="controls">--%>
                <%--<label class="lbl"><fmt:formatDate value="${sysUser.createDate}" type="both" dateStyle="full"/></label>--%>
            <%--</div>--%>
        <%--</div>--%>
        <%--<div class="control-group">--%>
            <%--<label class="control-label">最后登陆:</label>--%>
            <%--<div class="controls">--%>
                <%--<label class="lbl">IP: ${sysUser.loginIp}&nbsp;&nbsp;&nbsp;&nbsp;时间：<fmt:formatDate value="${sysUser.loginDate}" type="both" dateStyle="full"/></label>--%>
            <%--</div>--%>
        <%--</div>--%>
    <%--</c:if>--%>
    <div class="form-actions">
        <shiro:hasPermission name="sys:sysUser:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
        <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
    </div>
</form:form>
</body>
</html>